﻿set_primary_spouse_interaction = {
	category = interaction_category_diplomacy
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:actor.faith = {
						NOT = {
							religion = religion:islam_religion
						}
					}
				}
				desc = set_primary_spouse_interaction_desc
			}
			desc = set_primary_spouse_interaction_islam_desc
		}
	}
	icon = icon_marriage

	auto_accept = yes

	is_shown = {
		scope:actor = {
			is_spouse_of = scope:recipient
		}
		NOT = {
			scope:actor.primary_spouse = scope:recipient
		}
	}
	is_valid_showing_failures_only = {
		scope:recipient = { is_busy_in_events_localised = yes }
		scope:recipient = {
			NOT = {
				has_trait = incapable
			}
		}
		custom_tooltip = {
			text = switched_primary_spouse_flag_desc
			scope:actor = {
				NOT = { has_character_flag = switched_primary_spouse_flag }
			}
		}
	}

	on_accept = {
		set_primary_spouse_effect = yes
		scope:actor = {
			custom_tooltip = set_primary_spouse_effect_tooltip
			add_character_flag = {
				flag = switched_primary_spouse_flag
				years = 1
			}
			add_character_flag = {
				flag = recently_set_primary_spouse_flag
				years = 3
			}
		}
	}

	ai_targets = {
		ai_recipients = spouses
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency = 72

	ai_potential = {
		any_spouse = {
			count >= 2
		}
	}

	ai_will_do = {
		base = 0

		modifier = {
			scope:recipient = {
				has_character_flag = flag_new_consort
			}
			add = -25
		}
		modifier = { #Don't switch away from GC
			add = -75
			scope:actor = {
				employs_court_position = grand_consort_court_position
			}
			scope:recipient = {
				NOT = { has_court_position = grand_consort_court_position }
			}
		}
		modifier = { #Skills
			add = 25
			scope:recipient = {
				is_lowborn = no
				sum_of_all_skills_value > scope:actor.primary_spouse.sum_of_all_skills_value
			}
			scope:actor = {
				NOR = {
					has_relation_friend = scope:actor.primary_spouse
					has_relation_best_friend = scope:actor.primary_spouse
					has_relation_lover = scope:actor.primary_spouse
					has_relation_soulmate = scope:actor.primary_spouse
				}
			}
		}
		modifier = { #AI does it if current primary_spouse is hated and another spouse is preferred.
			add = 25
			scope:actor = {
				opinion = {
					target = scope:actor.primary_spouse
					value <= -50
				}
				opinion = {
					target = scope:recipient 
					value >= 1
				}
			}
		}
		modifier = { #The current PS comes from the high nobility
			add = -25
			scope:actor.primary_spouse = {
				any_close_family_member = {
					highest_held_title_tier >= tier_county
					OR = {
						is_councillor_of = scope:actor
						tier_difference = {
							target = scope:actor
							value >= 0
						}
					}	
				}
			}
		}
		modifier = { #The current PS comes from the high nobility
			add = -25
			scope:actor.primary_spouse = {
				any_close_family_member = {
					highest_held_title_tier >= tier_county
					OR = {
						is_powerful_vassal_of = scope:actor
						tier_difference = {
							target = scope:actor
							value >= 1
						}
					}	
				}
			}
		}
		modifier = { #The current PS comes from the high nobility
			add = -25
			scope:actor.primary_spouse = {
				any_close_family_member = {
					is_liege_or_above_of = scope:actor
				}
			}
		}
		modifier = { #Nobility
			add = -25
			scope:recipient = {
				is_lowborn = yes
			}
			scope:actor.primary_spouse = {
				is_lowborn = no
			}
		}
		modifier = { #The recipient comes from the high nobility
			add = 25
			scope:recipient = {
				any_close_family_member = {
					highest_held_title_tier >= tier_county
					OR = {
						is_councillor_of = scope:actor
						tier_difference = {
							target = scope:actor
							value >= 0
						}
					}	
				}
			}
		}
		modifier = { #The recipient comes from the high nobility
			add = 25
			scope:recipient = {
				any_close_family_member = {
					highest_held_title_tier >= tier_county
					OR = {
						is_powerful_vassal_of = scope:actor
						tier_difference = {
							target = scope:actor
							value >= 1
						}
					}	
				}
			}
		}
		modifier = { #The recipient comes from the high nobility
			add = 25
			scope:recipient = {
				any_close_family_member = {
					is_liege_or_above_of = scope:actor
				}
			}
		}
		modifier = { #Relations
			add = -50
			scope:actor = {
				OR = {
					has_relation_friend = scope:actor.primary_spouse
					has_relation_best_friend = scope:actor.primary_spouse
					has_relation_lover = scope:actor.primary_spouse
					has_relation_soulmate = scope:actor.primary_spouse
				}
			}
		}
		modifier = { #Children
			add = -35
			scope:actor.primary_spouse = {
				any_child = {
					is_player_heir_of = scope:actor
				}
			}
		}
		modifier = { #Favor
			add = -15
			scope:actor.primary_spouse = {
				has_variable = favor
				var:favor >= neutral_consort_lower_limit
			}
		}
		modifier = { #Favor
			add = -10
			scope:actor.primary_spouse = {
				has_variable = favor
				var:favor >= favorite_consort_lower_limit
			}
		}
		modifier = { #Favor
			add = -10
			scope:actor.primary_spouse = {
				OR = {	
					AND = {
						has_variable = favor
						var:favor >= beloved_consort_lower_limit
					}
					has_character_modifier = favor_boost_modifier
				}
			}
		}
		modifier = { #Landed relatives
			add = 15
			scope:actor.primary_spouse = {
				any_close_family_member = {
					is_landed_or_landless_administrative = yes
				}
			}
			scope:recipient = {
				is_landed_or_landless_administrative = no
			}
		}
		modifier = { #Recently did it
			add = -75
			scope:actor = {
				has_character_flag = recently_set_primary_spouse_flag
				NOT = { has_trait = fickle }
			}
		}
		modifier = { #Recently did it
			add = 25
			scope:actor = {
				has_character_flag = recently_set_primary_spouse_flag
				has_trait = fickle
			}
			scope:recipient = {
				has_character_modifier = demoted_primary_spouse_modifier
			}
		}
		modifier = {
			factor = 0.5
			scope:actor = {
				has_trait = stubborn
			}
		}
		modifier = {
			factor = 0
			scope:actor = {
				OR = {
					has_trait = forgiving
					has_trait = compassionate
				}
			}
		}
	}
}

promote_grand_consort_interaction = {
	category = interaction_category_diplomacy
	desc = promote_grand_consort_interaction_desc
	icon = icon_declare_me_regent

	auto_accept = yes

	is_shown = {
		scope:actor = {
			is_ai = no
			is_physically_able = yes
			gold >= 1
			can_appoint_char_to_court_position = {
				CHAR = scope:recipient
				COURT_POS = grand_consort_court_position
			}
		}
	}
	is_valid_showing_failures_only = {
		scope:recipient = { 
			is_physically_able = yes
		}
		scope:actor = {
			NOR = {
				government_has_flag = government_is_tribal
				government_has_flag = government_is_nomadic
				government_has_flag = government_is_herder
			}
		}
	}

	on_accept = {
		scope:actor = {
			appoint_court_position = {
				recipient = scope:recipient
				court_position = grand_consort_court_position
			}
		}
	}
}

revoke_grand_consort_interaction = {
	category = interaction_category_diplomacy
	desc = revoke_grand_consort_interaction_desc
	icon = icon_dismiss_temporary_regency

	auto_accept = yes

	is_shown = {
		scope:recipient = {
			is_grand_consort_trigger = yes
			is_courtier_of = scope:actor
			is_consort_of = scope:actor
		}
		scope:actor = {
			is_ai = no
		}
	}
	is_valid_showing_failures_only = {
		scope:recipient = { 
			is_busy_in_events_localised = yes
		}
	}

	on_accept = {
		scope:actor = {
			revoke_court_position = {
				recipient = scope:recipient
				court_position = grand_consort_court_position
			}
		}
	}
}


#Favor modifiers
boost_favor_consort_interaction = {
	category = interaction_category_diplomacy
	desc = boost_favor_consort_interaction_desc
	icon = icon_personal

	cost = {
		prestige = {
			value = 0
			#Costly if recipient is forgotten or already favored
			if = {
				limit = {
					scope:recipient = {
						OR = {	
							var:favor < unfavored_consort_lower_limit
							var:favor >= favorite_consort_lower_limit
						}
					}
				}
				add = major_prestige_value
			}
			#Cheaper if unfavored
			else_if = {
				limit = {
					scope:recipient = {
						var:favor < neutral_consort_lower_limit
					}
				}
				add = minor_prestige_value
			}
			#A bit cheaper if neutral
			else = {
				add = medium_prestige_value
			}
		}
	}

	auto_accept = yes

	is_shown = {
		scope:actor = {
			is_ai = no
			is_physically_able = yes
			any_consort = {
				is_courtier_of = scope:actor
				is_alive = yes
				is_incapable = no
				OR = {
					is_imprisoned_by = scope:actor
					is_imprisoned = no
				}
				has_variable = favor
				count >= 4
			}
		}
		scope:recipient = {
			has_variable = favor
			is_consort_of = scope:actor
			is_courtier_of = scope:actor
			is_demoted_consort_trigger = no
		}
	}
	is_valid_showing_failures_only = {
		scope:recipient = { 
			is_busy_in_events_localised = yes
			is_available = yes
		}
		#Is not already favored
		custom_tooltip = {
			text = already_favored_recipient
			scope:recipient = {
				NOR = {
					has_character_modifier = beloved_consort_modifier
					has_character_modifier = favor_boost_modifier
				}
			}
		}
		#Has not favored someone already
		custom_tooltip = {
			text = already_favored_consort
			scope:actor = {
				NOT = {
					has_character_flag = already_favored_consort_flag
				}
			}
		}
		#Has recently unfavored this consort
		custom_tooltip = {
			text = recently_unfavored_consort_desc
			scope:recipient = {
				NOT = {
					has_character_flag = recently_unfavored_consort
				}
			}
		}
		#The GC is balancing favor
		custom_tooltip = {
			text = grand_consort_balancing_favor
			scope:actor = {
				NOT = {
					any_courtier = {
						has_court_position = grand_consort_court_position
						has_character_flag = gc_balancing_favor_flag
					}
				}
			}
		}
	}

	on_accept = {
		scope:recipient = {
			calyver_favor_minor_gain_effect = yes
			add_character_modifier = {
				modifier = favor_boost_modifier
				years = 3
			}
			if = {
				limit = {
					hp_accepts_harems = yes
					NOT = {
						has_opinion_modifier = {
							modifier = forced_me_concubine_marriage_opinion
							target = scope:actor
						}
					}
				}
				if = {
					limit = { 
						OR = {
							has_trait = arrogant
							has_trait = greedy
							has_trait = ambitious
						}
					}
					add_opinion = {
						target = scope:actor
						modifier = grateful_opinion
						opinion = 20
					}
				}
				else_if = {
					limit = { 
						harem_politics_evil_consort_trigger = yes
					}
					add_opinion = {
						target = scope:actor
						modifier = grateful_opinion
						opinion = 15
					}
				}
				else = {
					add_opinion = {
						target = scope:actor
						modifier = grateful_opinion
						opinion = 10
					}
				}
			}
			custom_tooltip = jealous_consorts_tooltip
		}
		scope:actor = {
			add_character_flag = {
				flag = already_favored_consort_flag
				years = 3
			}
			hidden_effect = {
				send_interface_toast = {
					type = event_generic_good #Check
					title = boosted_consort_favor_t
					left_icon = scope:recipient

					show_as_tooltip = {
						scope:recipient = {
							add_character_modifier = {
								modifier = favor_boost_modifier
								years = 3
							}
							if = {
								limit = {
									scope:recipient = {
										hp_accepts_harems = yes
										NOT = {
											has_opinion_modifier = {
												modifier = forced_me_concubine_marriage_opinion
												target = scope:actor
											}
										}
									}
								}
								if = {
									limit = { 
										scope:recipient = {
											OR = {
												has_trait = arrogant
												has_trait = greedy
												has_trait = ambitious
											}
										}
									}
									add_opinion = {
										target = scope:actor
										modifier = grateful_opinion
										opinion = 20
									}
								}
								else_if = {
									limit = { 
										scope:recipient = {
											harem_politics_evil_consort_trigger = yes
										}
									}
									add_opinion = {
										target = scope:actor
										modifier = grateful_opinion
										opinion = 15
									}
								}
								else = {
									add_opinion = {
										target = scope:actor
										modifier = grateful_opinion
										opinion = 10
									}
								}
							}
						}
					}
				}
				#Other consorts will get jealous
				every_consort = {
					limit = {
						NOT = {
							this = scope:recipient
						}
						hp_accepts_harems = yes
						NOR = {
							has_opinion_modifier = {
								modifier = forced_me_concubine_marriage_opinion
								target = scope:actor
							}
							has_sexuality = homosexual
							has_sexuality = asexual

							has_relation_rival = scope:actor
							has_relation_nemesis = scope:actor
						}
						is_courtier_of = scope:actor
						is_incapable = no
						is_imprisoned = no
					}
					#Beloved ones will feel threatened
					if = {
						limit = {
							has_character_modifier = beloved_consort_modifier
							NOR = {
								has_trait = content
								has_trait = humble
								has_trait = forgiving
							}
						}
						add_opinion = {
							target = scope:recipient
							modifier = jealousy_opinion
							opinion = -10
						}
					}
					#Favored ones too
					else_if = {
						limit = {
							OR = {	
								has_character_modifier = favored_consort_modifier
								has_trait = arrogant
								has_trait = greedy
								has_trait = ambitious
							}
						}
						add_opinion = {
							target = scope:recipient
							modifier = jealousy_opinion
							opinion = -5
						}
					}
					#Evil ones are resentful, and just consorts know that favor monopoly isn't fair
					if = {
						limit = {
							OR = {	
								harem_politics_evil_consort_trigger = yes
								has_trait = just
							}
						}
						add_opinion = {
							target = scope:recipient
							modifier = jealousy_opinion
							opinion = -5
						}
					}
					if = {
						limit = {
							OR = {	
								has_character_flag = recently_unfavored_consort
								has_character_modifier = unfavored_consort_modifier
								has_character_modifier = forgotten_consort_modifier
							}
							NOR = {
								has_trait = content
								has_trait = temperate
								has_trait = calm
								has_trait = forgiving
								has_trait = compassionate
							}
						}
						add_opinion = {
							target = scope:recipient
							modifier = jealousy_opinion
							opinion = -5
						}
					}
				}
				random_list = {
					25 = { #Your consorts protest this favor
						modifier = { #Traits
							scope:recipient = { has_trait = beauty_good_2 }
							add = 10
						}
						modifier = { #Traits
							scope:recipient = { has_trait = beauty_good_3 }
							add = 20
						}
						modifier = { #High favor
							scope:recipient = { var:favor >= favorite_consort_lower_limit }
							add = 20
						}
						modifier = {
							scope:recipient = { 
								has_opinion_modifier = {
									modifier = forced_me_concubine_marriage_opinion
									target = scope:actor
								}
							}
							add = 15
						}

						#The GC
						#High aptitude
						modifier = {
							scope:actor = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position >= 3
									has_character_flag = gc_promoting_harmony
								}
							}
							add = -7
						}
						modifier = {
							scope:actor = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position >= 4
									has_character_flag = gc_promoting_harmony
								}
							}
							add = -6
						}
						modifier = {
							scope:actor = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position = 5
									has_character_flag = gc_promoting_harmony
								}
							}
							add = -5
						}
						#Low aptitude
						modifier = {
							scope:actor = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position <= 2
									has_character_flag = gc_promoting_harmony
								}
							}
							add = 6
						}
						modifier = {
							scope:actor = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position = 1
									has_character_flag = gc_promoting_harmony
								}
							}
							add = 7
						}

						trigger_event = {
							id = harem_politics.0027
							days = { 7 365 }
						}
					}
					25 = { #Nothing
						#The GC
						#High aptitude
						modifier = {
							scope:actor = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position >= 3
									has_character_flag = gc_promoting_harmony
								}
							}
							add = 5
						}
						modifier = {
							scope:actor = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position >= 4
									has_character_flag = gc_promoting_harmony
								}
							}
							add = 6
						}
						modifier = {
							scope:actor = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position = 5
									has_character_flag = gc_promoting_harmony
								}
							}
							add = 7
						}
						#Low aptitude
						modifier = {
							scope:actor = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position <= 2
									has_character_flag = gc_promoting_harmony
								}
							}
							add = -6
						}
						modifier = {
							scope:actor = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position = 1
									has_character_flag = gc_promoting_harmony
								}
							}
							add = -7
						}
					}
				}
			}
		}
	}
}

stop_favor_boost_consort_interaction = {
	category = interaction_category_diplomacy
	desc = stop_favor_boost_consort_interaction_desc
	icon = icon_personal

	auto_accept = yes

	is_shown = {
		scope:recipient = {
			has_character_modifier = favor_boost_modifier
		}
		scope:actor = {
			is_ai = no
		}
	}

	on_accept = {
		calyver_stop_favor_boost_effect = {
			HAREM_LIEGE = scope:actor
			CONSORT = scope:recipient
		}
	}
}

# Debug - switch to player
switch_to_player_interaction = {
	category = interaction_category_diplomacy
	desc = switch_to_player_interaction_desc
	icon = icon_scheme_challenge_status

	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	common_interaction = yes
	auto_accept = yes

	is_shown = {
		debug_only = yes
		scope:actor = {
			is_ai = no
		}
		scope:recipient = {
			this != scope:actor
			is_ai = yes
			is_playable_character = yes
		}
	}

	can_send = {
		scope:actor = {
			is_ai = no
		}
	}

	on_accept = {
		scope:actor = {
			save_scope_as = harem_liege
			set_player_character = scope:recipient
		}
	}
	ai_will_do = 0
}

#Bestow Nobility#
# bestow_nobility_interaction = {
# 	category = interaction_category_diplomacy
# 	desc = bestow_nobility_interaction_desc
# 	icon = icon_personal #Check

# 	cost = {
# 		prestige = major_prestige_value
# 		gold = major_gold_value
# 	}

# 	auto_accept = yes

# 	is_shown = {
# 		debug_only = yes
# 		scope:actor = {
# 			is_physically_able = yes
# 			is_landed_or_landless_administrative = yes
# 			is_lowborn = no
# 		}
# 		scope:recipient = {
# 			is_lowborn = yes
# 			OR = {
# 				is_consort_of = scope:actor
# 				is_knight_of = scope:actor
# 				any_court_position_employer = scope:actor
# 				is_councillor_of = scope:actor
# 				any_close_family_member = {
# 					is_consort_of = scope:actor
# 				}
# 			}
# 			is_courtier_of = scope:actor
# 			trigger_if = {
# 				limit = {
# 					NOT = {
# 						character_gender_can_inherit_from_trigger = { CHARACTER = scope:actor }
# 					}
# 				}
# 				is_consort_of = scope:actor
# 			}
# 			trigger_else = {
# 				character_gender_can_inherit_from_trigger = { CHARACTER = scope:actor }
# 			}
# 		}
# 	}
# 	is_valid_showing_failures_only = {
# 		scope:recipient = { 
# 			is_busy_in_events_localised = yes
# 			is_available = yes
# 		}
# 	}

# 	on_accept = {
# 		scope:actor = {
# 			save_scope_value_as = {
# 				name = target_gold
# 				value = major_gold_value
# 				divide = 2
# 			}
# 		}
# 		scope:recipient = {
# 			if = {
# 				limit = {
# 					is_consort_of = scope:actor
# 					NOT = {
# 						character_gender_can_inherit_from_trigger = { CHARACTER = scope:actor }
# 					}
# 					any_close_family_member = {
# 						NOT = {
# 							is_child_of = scope:actor
# 						}
# 						character_gender_can_inherit_from_trigger = { CHARACTER = scope:actor }
# 						OR = {
# 							any_liege_or_above = {
# 								this = scope:actor
# 							}
# 							AND = {
# 								exists = scope:actor.top_liege
# 								top_liege ?= scope:actor.top_liege
# 							}
# 						}
# 						is_lowborn = yes
# 					}
# 				}
# 				random_close_family_member = {
# 					limit = {
# 						NOT = {
# 							is_child_of = scope:actor
# 						}
# 						character_gender_can_inherit_from_trigger = { CHARACTER = scope:actor }
# 						OR = {
# 							any_liege_or_above = {
# 								this = scope:actor
# 							}
# 							AND = {
# 								exists = scope:actor.top_liege
# 								top_liege ?= scope:actor.top_liege
# 							}
# 						}
# 						is_lowborn = yes
# 					}
# 					weight = {
# 						base = 1
# 						modifier = {
# 							is_parent_of = scope:recipient
# 							add = 49
# 						}
# 						modifier = {
# 							is_sibling_of = scope:recipient
# 							add = 24
# 						}
# 					}
# 					save_scope_as = target
# 				}
# 			}
# 			else = {
# 				save_scope_as = target
# 			}
# 		}
# 		scope:target = {
# 			if = {
# 				limit = {
# 					is_knight_of = scope:actor
# 				}
# 			}
# 			if = {
# 				limit = {
# 					is_councillor_of = scope:actor
# 				}
# 			}
# 			if = {
# 				limit = {
# 					any_court_position_employer = scope:actor
# 				}
# 			}
# 			hidden_effect = {
# 				scope:consort_relative = {
# 					add_short_term_gold = target_gold
# 					create_dynamic_title = {
# 						tier = duchy
# 						name = NEW_CREATED_TITLE_NAME
# 					}
# 					create_title_and_vassal_change = {
# 						type = created
# 						save_scope_as = change
# 						add_claim_on_loss = no
# 					}
# 					scope:new_title = {
# 						set_capital_county = scope:actor.capital_county
# 						set_landless_title = yes
# 						set_destroy_on_gain_same_tier = yes
# 						set_no_automatic_claims = yes
# 						set_can_be_named_after_dynasty = no
# 						change_title_holder = {
# 							holder = prev
# 							change = scope:change
# 						}
# 					}
# 					resolve_title_and_vassal_change = scope:change
# 					scope:new_title = {
# 						generate_coa = yes
# 					}
# 					destroy_title = scope:new_title
# 					if = { #Promote their relatives too
# 						limit = {
# 							any_close_family_member = {
# 								is_lowborn = yes
# 							}
# 						}
# 						every_close_family_member = {
# 							limit = {
# 								is_lowborn = yes
# 							}
# 							add_to_list = target_relatives_list
# 						}
# 					}
# 					if = { #And consorts
# 						limit = {
# 							NOT = {
# 								this = scope:recipient
# 							}
# 							any_consort = {
# 								is_lowborn = yes
# 								is_parent_of = scope:recipient
# 							}
# 						}
# 						every_consort = {
# 							limit = {
# 								is_lowborn = yes
# 								is_parent_of = scope:recipient
# 							}
# 							add_to_list = target_relatives_list
# 						}
# 					}
# 					if = {
# 						limit = {
# 							any_in_list = {
# 								list = target_relatives_list
# 								count >= 1
# 							}
# 						}
# 						every_in_list = {
# 							list = target_relatives_list
# 							limit = {
# 								is_lowborn = yes
# 							}
# 							set_house = scope:target.house
# 						}
# 					}
# 					if = { #Add their relatives to court
# 						limit = {
# 							any_close_family_member = {
# 								NOT = {
# 									is_courtier_of = scope:actor
# 								}
# 								OR = {
# 									top_liege ?= scope:actor
# 									NOR = {
# 										is_councillor = yes
# 										has_any_court_position = yes
# 										any_consort = {
# 											is_landed = yes
# 										}
# 									}
# 								}
# 							}
# 						}
# 						every_close_family_member = {
# 							limit = {
# 								NOT = {
# 									is_courtier_of = scope:actor
# 								}
# 								OR = {
# 									top_liege ?= scope:actor
# 									NOR = {
# 										is_councillor = yes
# 										has_any_court_position = yes
# 										any_consort = {
# 											is_landed = yes
# 										}
# 									}
# 								}
# 							}
# 							add_to_list = relatives_to_add_list
# 						}
# 					}
# 					if = { #And consorts
# 						limit = {
# 							any_consort = {
# 								NOT = {
# 									is_courtier_of = scope:actor
# 								}
# 								OR = {
# 									top_liege ?= scope:actor
# 									NOR = {
# 										is_councillor = yes
# 										has_any_court_position = yes
# 										any_consort = {
# 											is_landed = yes
# 										}
# 									}
# 								}
# 							}
# 						}
# 						every_consort = {
# 							limit = {
# 								NOT = {
# 									is_courtier_of = scope:actor
# 								}
# 								OR = {
# 									top_liege ?= scope:actor
# 									NOR = {
# 										is_councillor = yes
# 										has_any_court_position = yes
# 										any_consort = {
# 											is_landed = yes
# 										}
# 									}
# 								}
# 							}
# 							add_to_list = relatives_to_add_list
# 						}
# 					}
# 					if = {
# 						limit = {
# 							any_in_list = {
# 								list = relatives_to_add_list
# 								count >= 1
# 							}
# 						}
# 						every_in_list = {
# 							list = relatives_to_add_list
# 							scope:actor = {
# 								add_courtier = prev
# 							}
# 						}
# 					}
# 				}
# 				scope:actor = {
# 					add_courtier = scope:target
# 					# every_consort = {
# 					# 	limit = {
# 					# 		AND = {
# 					# 			NOR = {
# 					# 				this = scope:consort
# 					# 				any_close_or_extended_family_member = {
# 					# 					this = scope:consort
# 					# 				}
# 					# 				has_relation_best_friend = scope:consort
# 					# 				has_relation_friend = scope:consort
# 					# 				has_relation_lover = scope:consort
# 					# 				has_relation_soulmate = scope:consort
# 					# 			}
# 					# 			harem_politics_evil_consort_trigger = yes
# 					# 		}
# 					# 	}
# 					# 	add_opinion = {
# 					# 		target = scope:consort
# 					# 		modifier = envy_consort_opinion
# 					# 	}
# 					# }
# 				}
# 				# scope:consort = {
# 				# 	send_interface_toast = {
# 				# 		type = event_generic_good
# 				# 		title = good_consort_visit_t
# 				# 		right_icon = scope:harem_liege
# 				# 		left_icon = scope:consort_relative
# 				# 		show_as_tooltip = {
# 				# 			calyver_favor_medium_gain_effect = yes
# 				# 		}
# 				# 		scope:consort_relative = {
# 				# 			add_opinion = {
# 				# 				target = scope:consort
# 				# 				modifier = grateful_opinion
# 				# 				opinion = 10
# 				# 			}
# 				# 			show_as_tooltip = {
# 				# 				set_house = scope:consort_relative.house
# 				# 				if = {
# 				# 					limit = {
# 				# 						exists = scope:consort.house
# 				# 						house ?= scope:consort.house
# 				# 					}
# 				# 					scope:consort = {
# 				# 						set_house = scope:consort_relative.house
# 				# 					}
# 				# 				}
# 				# 			}
# 				# 		}
# 				# 	}
# 				# }
# 			}
# 		}
# 	}
# }